//
//  DSPVistorViewController.swift
//  SWweibo
//
//  Created by 杜守鹏 on 15/12/28.
//  Copyright © 2015年 杜守鹏. All rights reserved.
//

import UIKit

class DSPVistorViewController: UITableViewController {
//    var userLogin:Bool = false
    lazy var userLogin:Bool = {
       
        if DSPDSPUserCountViewModel.account() == nil {
            return false
        }else{
            return true
        }
        
    }()
    
    lazy var loginCourse: ()->() = {
        print("登陆！！！")
        let vc = DSPOAuthViewController()
        self.presentViewController(vc, animated: true, completion: nil)
        
    }
    let regCourse = {
        print("注册！！！")
    }
    
    override func loadView() {
        userLogin == true ? super.loadView():setupBaseUI()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        vistorView.didregisterButton = regCourse
        vistorView.didLoginButton = loginCourse
    }

    func setupBaseUI(){
        view = vistorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem( title: "注册", target: self, action: "didClickregisterButton")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", target: self, action: "didClickLogin")
    }
    @objc private func didClickLogin(){
        let vc = DSPOAuthViewController()
        presentViewController(vc, animated: true, completion: nil)
        print("LOGIN")
    }
    
    @objc private  func didClickregisterButton(){
        print("REGISTER")
    }
 
    lazy var vistorView:DSPvistorView = DSPvistorView()
}
